Handle exceptions caused during processing of requests, to improve error
authoremellor@ewan <emellor@ewan>
Wed, 28 Sep 2005 12:41:44 +0000 (13:41 +0100)
committeremellor@ewan <emellor@ewan>
Wed, 28 Sep 2005 12:41:44 +0000 (13:41 +0100)
reporting.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
tools/python/xen/web/SrvBase.py

index 49a9e058d14726ab47db977d820adbf5d98eb169..e0b528fcc08766bc75c0dc9fc5369e50298cda59 100644 (file)
@@ -81,7 +81,14 @@ class SrvBase(resource.Resource):
             req.write("Operation not implemented: " + op)
             return ''
         else:
-            return op_method(op, req)
+            try:
+                res = op_method(op, req)
+            except Exception, exn:
+                log.exception("Request %s failed.", op)
+                if req.useSxp():
+                    return ['xend.err', "Exception: " + str(exn)]
+                else:
+                    return "<p>%s</p>" % str(exn)
 
     def print_path(self, req):
         """Print the path with hyperlinks.